﻿using System;
using Sunny.UI;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ClassLibrary;

namespace Forms
{
    public partial class ProfileForm : UIForm
    {
        User user = new User();
        User Sender = new User();
        MarketService MS = new MarketService();
        public ProfileForm(User user, Image image, User sender)
        {
            InitializeComponent();
            this.user = user;
            this.Sender = sender;

            NameLabel.Text = user.UserName;//个人信息初始化
            NameLabel2.Text = user.UserName;
            IDLabel.Text += user.UserID;
            TeleLabel.Text = user.UserTele;
            IDCardLabel.Text = user.UserIdentityCard;
            AddressLabel.Text = user.UserAddress;
            pictureBox1.Image = image;

            List<Market> Markets = new List<Market>();
            Markets = MS.GetMarketByUserID(user.UserID);//找到本人的超市
            foreach (Market market in Markets)//超市信息初始化
            {
                MarketIDLabel.Text = market.MarketID;
                MarketNameLabel.Text = market.MarketName;
                MarketAddressLabel.Text = market.MarketAddress;
                MarketTimeLabel.Text = market.MarketOperationTime;
            }

            //其他信息的初始化
            Color userColor = MainForm.MainForm.userColor;
            UIStyles.InitColorful(userColor, Color.White);
        }

        private void InBtn_Click(object sender, EventArgs e)
        {
            try
            {
                ChatForm cf = new ChatForm(user, Sender);
                cf.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}
